{{- $tfModel := ""}}
{{- $tfMapper := ""}}
{{- range .tplFiles}}
{{- if eq .Type "Model"}}{{$tfModel = .}}{{- end}}
{{- if eq .Type "Mapper"}}{{$tfMapper = .}}{{- end}}
{{- end}}

{{- $model := toCamel .table.Name}}{{- /*Mode名字*/}}
{{- $mapper := printf "%sMapper" $model }}{{- /*Mapper*/}}
{{- .ctx.Set "fileName" $mapper}}{{- /*设置输出文件名字*/}}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="{{$tfMapper.Package}}.{{$mapper}}">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="{{$tfModel.Package}}.{{$model}}">
        {{- range .table.Columns}}
        {{if .IsPrimaryKey}}<id column="{{.Name}}" property="{{toCamelLower .Name}}" />
        {{- else}}<result column="{{.Name}}" property="{{toCamelLower .Name}}" />
        {{- end}}
        {{- end}}
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        {{$len := len .table.Columns}}
        {{- range $idx,$val := .table.Columns}}
        {{- if eq $idx 0}}{{.Name}}{{- else}}, {{.Name}}{{end}}
        {{- if eq $idx 10}}
        {{""}}
        {{- end}}
        {{- $mod := mod $idx 10}}
        {{- if and (gt $idx 10) (eq $mod 0)}}
        {{""}}
        {{- end}}
        {{- end}}
    </sql>

</mapper>
